-module(reverl_sup).
-behaviour(supervisor).
-export([
	 start_link/0,
         init/1
        ]).

-define(SERVER, ?MODULE).

start_link() ->
    supervisor:start_link({local, ?SERVER}, ?MODULE, []).

init([]) ->
    Host = get_app_env(listen_host, "0.0.0.0"),
    Port = get_app_env(listen_port, 8080),
    Server = {reverl_server,{reverl_server,start_link,[Port]},
	     permanent,2000,worker,[reverl_server]},
    {ok,{{one_for_one,10,1}, [Server]}}.

get_app_env(Key, Default) ->
    case application:get_env(Key) of
        {ok, Val} -> Val;
        _         -> Default
    end.
